//
//  IndexViewController.m
//  EasyBuy
//
//  Created by shen donghao on 12-9-22.
//  Copyright (c) 2012年 shen donghao. All rights reserved.
//

#import "HomeViewController.h"
#import "EasyBuy.h"
#import "BuyInfoTableViewController.h"


@implementation HomeViewController
@synthesize homeTableView; 
@synthesize homeFocusView;
@synthesize _selectedSections;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.frame = SUBVIEWCONTROLLER_FRAME;
    
    self.title = @"首页";
    
    _selectedSections = [[NSMutableArray alloc] init];
    
    RecommendTableView *_tableView = [[RecommendTableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    _tableView.delegate = _tableView;
    _tableView.dataSource = _tableView;
    self.homeTableView = _tableView;
    [self.view addSubview:homeTableView];
    [_tableView release];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 120)];
    _tableView.tableHeaderView = view;
    
    FocusView *_focusView = [[FocusView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 120)];
    self.homeFocusView = _focusView;
    [_focusView release];
    [view addSubview:homeFocusView];
    
    
    
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self
											 selector:@selector(onReceivedControllerMsg:)
												 name:RECEIVER_HOME_VIEWCONTROLLER
											   object:nil];
    
    
}

-(void)onReceivedControllerMsg:(NSNotification *)notification{
    
    NSNumber *contentIdNumber = notification.object;
    BuyInfoTableViewController *buyInfoTableViewController = [[BuyInfoTableViewController alloc] init];
    buyInfoTableViewController.objectId = [contentIdNumber intValue];
    [self.navigationController pushViewController:buyInfoTableViewController animated:YES];
    [buyInfoTableViewController release];
}

//- (void)

- (void)dealloc
{
    [homeFocusView release];
    [homeTableView release];
    [_selectedSections release];
	[[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

@end
